import React, { Component, Fragment } from 'react'
import { Route, Switch, Redirect} from 'react-router-dom'
import AdminLayout from '_components/AdminLayout/AdminLayout.js'
import routes from '_routes'

class Admin extends Component {
  render() {
    return (
      <Fragment>
        <AdminLayout>
          <Switch>
                {
                  routes.map(route => {
                    return (
                      <Route key={route.path}
                        path={route.path}
                        component={route.component} />
                    )
                  })
                }
                {/* 当访问admin路由时，直接重定向到dashboard */}
                <Redirect to='/admin/dashboard' from='/admin' exact />
              </Switch>
        </AdminLayout>
      </Fragment>
    )
  }
}

export default Admin
